import userStateStorage from "./UserStateStorage.js";
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    storeName: uni.getStorageSync("storeName") || "",
    signName: uni.getStorageSync("signName") || "",
    storeLogo: uni.getStorageSync("storeLogo") || "",
    enableMatomo: uni.getStorageSync("enableMatomo") || "",
    enableYoushu: uni.getStorageSync("enableYoushu") || "",
    changeReportUrl: uni.getStorageSync("reportUrl") || "",
    changeSiteId: uni.getStorageSync("siteId") || "",
    imageScaling: 0,
    background: "",
    storeVersion: uni.getStorageSync("storeVersion"),
    tabInfo: null,
    smsTemplateId: uni.getStorageSync("smsTemplateId") || "1019",
    smsPlatform: uni.getStorageSync("smsPlatform") || "aliyun",
    cartNum: 0,
    isIpx: false,
    brandType: -1,
    arrivalNotice: false,
    buyNow: false,
    commonEnable: false,
    showPromotionTag: false,
    saleRemind: false, //开售提醒
    advanceTime: 0,
    saleTemplate: "",
    cmsDefaultShow: true,
    cmsDefaultShow1: true,
    cmsDefaultShow2: true,
    /** 注册改版 开始 */
    skdModalChecked: userStateStorage.getSdkModalState(), // SDK弹窗
    ageModalChecked: userStateStorage.getAgeModalState(), // 18周岁弹框
    /** 注册改版 结束 */
    tsTabbar: false,
    welcomeDialog: false,
    foreignMobileDialog: false,
    registerPageIsActive: false,
    isShowBalloutTimeNavbarTitle:false,//抽签购plp 横幅展示状态
  },
  getters: {
    doneTodosCount: (state) => {
      return state.tabInfo;
    },
  },

  mutations: {
    changeSkdModalCheckedState(state, value) {
      state.skdModalChecked = value;
      userStateStorage.setSdkModalState(value);
    },
    changeAgeModalCheckedState(state, value) {
      state.ageModalChecked = value;
      userStateStorage.setAgeModalState(value);
    },
    changeStoreName: function (state, name) {
      state.storeName = name;
    },
    changeStoreLogo: function (state, logo) {
      state.storeLogo = logo;
    },
    changeCommonEnable: function (state, commonEnable) {
      state.commonEnable = commonEnable;
    },
    changeArrivalNotice: function (state, arrivalNotice) {
      state.arrivalNotice = arrivalNotice;
    },
    changeBuyNow: function (state, buyNow) {
      state.buyNow = buyNow;
    },
    changeSignName: function (state, signName) {
      state.signName = signName;
    },
    changeStoreVersion: function (state, version) {
      state.storeVersion = version;
    },
    changeBackground: function (state, background) {
      state.background = background;
    },
    setTabInfo: function (state, info) {
      state.tabInfo = info;
    },
    changeEnableMatomo: function (state, enable) {
      state.enableMatomo = enable;
    },
    changeEnableYoushu: function (state, enable) {
      state.enableYoushu = enable;
    },
    changeSiteId: function (state, siteId) {
      state.siteId = siteId;
    },
    changeReportUrl: function (state, reportUrl) {
      state.reportUrl = reportUrl;
    },
    changeImageScaling: function (state, imageScaling) {
      state.imageScaling = imageScaling;
    },
    changeSmsTemplateid: function (state, smsTemplateId) {
      state.smsTemplateId = smsTemplateId;
    },
    changeSmsPlatform: function (state, smsPlatform) {
      state.smsPlatform = smsPlatform;
    },
    changeCartNum: function (state, cartNum) {
      state.cartNum = cartNum;
    },
    changeIsIpx: function (state, isIpx) {
      state.isIpx = isIpx;
    },
    changeBrandType: function (state, brandType) {
      state.brandType = brandType;
    },
    changeShowCheckoutRemark: function (state, showCheckoutRemark) {
      state.showCheckoutRemark = showCheckoutRemark;
    },
    changeShowPromotionTag: function (state, showPromotionTag) {
      state.showPromotionTag = showPromotionTag;
    },
    changeShowTimeTag: function (state, showTimeTag) {
      state.showTimeTag = showTimeTag;
    },

    changeSaleRemindStatus: function (state, saleRemind) {
      state.saleRemind = saleRemind;
    },
    changeAdvanceTime: function (state, advanceTime) {
      state.advanceTime = advanceTime;
    },
    changeSaleTemplate: function (state, saleTemplate) {
      state.saleTemplate = saleTemplate;
    },
    changecmsDefaultShowStatus: function (state, cmsDefaultShow) {
      state.cmsDefaultShow = cmsDefaultShow;
    },
    changecmsDefaultShow1Status: function (state, cmsDefaultShow1) {
      state.cmsDefaultShow1 = cmsDefaultShow1;
    },
    changecmsDefaultShow2Status: function (state, cmsDefaultShow2) {
      state.cmsDefaultShow2 = cmsDefaultShow2;
    },
    changeTstabbar(state, value) {
      state.tsTabbar = value;
    },
    changeWelcomeDialogStatus(state, value) {
      state.welcomeDialog = value;
    },
    changeIsForeignMobile(state, value) {
      state.foreignMobileDialog = value;
    },
    changeregisterAgreeToContinueIsActive(state, value) {
      state.registerPageIsActive = value;
    },
    // 抽签购plp 横幅展示状态
    isShowBalloutTimeNavbarTitleState(state, value) {
      state.isShowBalloutTimeNavbarTitle = value;
    },
  },
});

export default store;
